package com.ivo.act.config;

import org.activiti.engine.ProcessEngine;
import org.activiti.spring.ProcessEngineFactoryBean;
import org.activiti.spring.SpringProcessEngineConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionManager;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @author wj
 * @version 1.0
 */
@Configuration
public class ActivitiConfig extends AbstractProcessEngineConfiguration {

    @Resource
    private DataSource dataSource;

    @Resource
    private PlatformTransactionManager transactionManager;

    @Bean
    SpringProcessEngineConfiguration springProcessEngineConfiguration() {
        SpringProcessEngineConfiguration springProcessEngineConfiguration = new SpringProcessEngineConfiguration();
        springProcessEngineConfiguration.setDataSource(dataSource);
        springProcessEngineConfiguration.setDatabaseSchemaUpdate("false");
        springProcessEngineConfiguration.setJobExecutorActivate(false);
        springProcessEngineConfiguration.setHistory("full");
        springProcessEngineConfiguration.setTransactionManager(transactionManager);

        return springProcessEngineConfiguration;
    }
}
